package Server;


import Server.ExtComponents.BaseConfig.config;
import Server.ExtComponents.MyBatis.OrmProviderFactory;
import Server.ExtComponents.socket.MServerFrameNettyStart;


import Server.ServerCore.Service.usyns.SingelTableManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import javax.annotation.Resource;

/**
 * 服务器入口
 */
public class GameServer_21{

    private static final Logger LOG = LoggerFactory.getLogger(GameServer_21.class);


    @Resource
    private OrmProviderFactory providerFactory;

    @Resource
    private MServerFrameNettyStart frameNettyStart;

    @Resource
    private SingelTableManager singelTableManager;


    public static void main(String[] args) {
        try {
            //close the warn in logger,set system property
            System.setProperty( "org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog" );
            BeanFactory springContext = new FileSystemXmlApplicationContext(config.SPRING_CONFIG_PATH);
            GameServer_21 gameServer = (GameServer_21) springContext.getBean("gameServer");
            /**先初始化服务器端基础数据，最后启动通信层*/
            gameServer.frameNettyStart.startServer();
            /**初始化mybatis 注册映射关系**/
            gameServer.providerFactory.IntiOrm();
            // 初始化table
            gameServer.singelTableManager.InitSingelTables();
        } catch (Exception e) {
            LOG.error("server start error", e);
        }

    }

}
